import 'package:share_fit/app/helper/ext/tr_ext.dart';
import 'package:share_fit/generated/locales.g.dart';

class GoalSettingState {
  final List<String> tabTitleList = [];

  final List<Map<String, Object>> durationList = [];
  final List<Map<String, Object>> distanceList = [];
  final List<Map<String, Object>> calorieList = [];

  String inputHours = '00';
  String inputMinutes = '10';
  String inputSeconds = '00';

  /// 保存用户输入的时长
  String durationValue = '';

  /// 控制自定义时长保存按钮是否可以点击
  bool canSaveDistance = false;

  String selectedDuration = '00:10:00';
  // String selectedDuration = '10';


  String selectedDistance = '0';
  String distancePartOne = '';
  String distancePartTwo = '';

  String selectedCalorie = '0';

  /// 默认运动类型
  var sportType = 1;

  /// 是否显示提示文本
  bool showDurationWarning = false;

  bool canSaveCalories = false;

  bool canSaveDuration = false;

  GoalSettingState() {
    ///Initialize variables
    tabTitleList.add(LocaleKeys.sports_goal_duration_text.ts);
    tabTitleList.add(LocaleKeys.sports_goal_distance_text.ts);
    tabTitleList.add(LocaleKeys.sports_goal_calories_text.ts);

    // durationList.add({'label': '10', 'value': 10});
    // durationList.add({'label': '20', 'value': 20});
    // durationList.add({'label': '30', 'value': 30});
    // durationList.add({'label': '60', 'value': 60});
    // durationList.add({'label': '120', 'value': 120});
    // durationList.add({'label': '180', 'value': 180});

    durationList.add({'label': '00:10:00', 'value': '00:10:00'});
    durationList.add({'label': '00:20:00', 'value': '00:20:00'});
    durationList.add({'label': '00:30:00', 'value': '00:30:00'});
    durationList.add({'label': '00:40:00', 'value': '00:40:00'});
    durationList.add({'label': '00:50:00', 'value': '00:50:00'});
    durationList.add({'label': '01:00:00', 'value': '01:00:00'});
    durationList.add({'label': '01:10:00', 'value': '01:10:00'});

    distanceList.add({'label': '1', 'value': 1});
    distanceList.add({'label': '3', 'value': 3});
    distanceList.add({'label': '5', 'value': 5});
    distanceList.add({'label': '10', 'value': 10});
    distanceList.add({'label': '21', 'value': 21});
    distanceList.add({'label': '42', 'value': 42});

    calorieList.add({'label': '100', 'value': 100});
    calorieList.add({'label': '200', 'value': 200});
    calorieList.add({'label': '300', 'value': 300});
    calorieList.add({'label': '500', 'value': 500});
    calorieList.add({'label': '600', 'value': 600});
    calorieList.add({'label': '800', 'value': 800});
  }

  String get hMSValue => '$hoursValue:$minutesValue:$secondsValue';

  String get hoursValue {
    return inputHours.isEmpty
        ? '00'
        : int.parse(inputHours) < 10
            ? '0${int.parse(inputHours)}'
            : inputHours;
  }

  String get minutesValue {
    return inputMinutes.isEmpty
        ? '00'
        : int.parse(inputMinutes) < 10
            ? '0${int.parse(inputMinutes)}'
            : inputMinutes;
  }

  String get secondsValue {
    return inputSeconds.isEmpty
        ? '00'
        : int.parse(inputSeconds) < 10
            ? '0${int.parse(inputSeconds)}'
            : inputSeconds;
  }
}
